<? FoundryView::includeTpl( 'adminMain:header' ) ?>

<script type="text/javascript" src="<?=Foundry::config('webpath')?>/javascript/admin/editToolBar.js"></script>


<div id="mainContent">

	<h2>Pages</h2>
	
	<a href="<?=FoundryView::helperLinkTo( 'pageAdmin/edit' )?>" class="actionLink">
		<img src="<?=Foundry::config('webpath')?>/images/admin/add.png" />
		new page</a>
	<span id="actionMessage"></span>
	
	<div class="actionForm">
		<form method="post" action="<?=FoundryView::helperLinkTo('pageAdmin/edit')?>/<?=$this->data['page']->uid?>">

		<div class="cellLeft">
	
			<input type="hidden" name="k" value="<?=$this->data['key']?>" />
			<label for="postTitle">Title</label>
			<input type="text" name="pageTitle" value="<?=$this->data['page']->title?>" /><p />
						
			<label for="pageContent">Content</label>
			<div id="pageContentToolBar"></div>
			<script type="text/javascript">
				ToolBar.create( 'pageContentToolBar',
					'pageContent' );
			</script>

			<textarea rows="20" cols="55" name="pageContent" id="pageContent"><?=$this->data['page']->content?></textarea><p />
			<p />
			<input type="submit" value="Save" />
			<a href="<?=FoundryView::helperLinkTo( 'pageAdmin/' )?>" class="cancelLink">
				Cancel</a>
		</div>
		<div class="cellRight">
			<label for="newsStatus">Publication Status</label>
				<input type="checkbox" name="pagePublished" value="1" <?php if( $this->data['page']->published == 1 ) { echo 'checked="checked"'; } ?> />
				This page is published
			<p />

			<label for="newsStatus">Tags</label>
			<select name="pageTagID[]" multiple="multiple">
			<?php
			
				$tagModel = FoundryController::model( 'tag' );
				$tags = $tagModel->find( 'order by *name' );
				foreach( $tags as $tag ) {
					echo '<option value="'.$tag->uid.'"';
					
					if( in_array( $tag->uid, $this->data['pageTags'] ) ) {
						echo ' selected="selected"';
					}
					
					echo '>'.$tag->name.'</option>';
				}
			?>
			</select><p />
			
		</div>
		<br class="cellBottom" />
		
		</form>
	</div>	
	
</div>
<?php if( FoundryRequest::get( 'msg' ) == 'sv' ) : ?>
<script type="text/javascript">
	actionMessage( 'Page Saved' );
</script>
<?php endif ?>

<? FoundryView::includeTpl( 'adminMain:footer' ) ?>